package nori6_common_protocol;

import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

public class Nori6IncomingMessage extends Nori6Message
{
	public Nori6IncomingMessage(String message)
	{
		JSONParser parser = new JSONParser();
		try
		{
			m_Json = (JSONObject)parser.parse(message);
			long i = (long)m_Json.get(ctrl_key);
			m_Controller = NORI6_CONTROLLER_TYPE.values()[(int)i];
		}
		catch(ParseException e)
		{
			System.out.println("Parsing failed. " + e.getMessage());
		}
	}
	
	public NORI6_CONTROLLER_TYPE GetController()
	{
		return m_Controller;
	}
	
	public Object GetField(String name)
	{
		return m_Json.get(name);
	}
}
